package logic.nodes.damagable.shield;

import com.jme.scene.Controller;

public class ShieldsController extends Controller {
	
	private static final long serialVersionUID = 1L;
	
	public static final float MAX_TIME = 1.6f;
	
	private ShieldEffectObject shields;
	private float currentTime;
	
	public ShieldsController(ShieldEffectObject shields) {
		this.shields = shields;
	}
	
	@Override
	public void update(float time) {
		currentTime += time;
		if(currentTime >= MAX_TIME) shields.disable();
		else {
			float diff = MAX_TIME - currentTime;
			float a = 1f - diff / MAX_TIME;
			shields.setAlpha(a);
		}
	}
}